package com.shuzi.MediaShare.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.shuzi.MediaShare.R;

/**
 * 二级页面的标题栏
 * 
 * @author lung 下午2:26:06 2013
 */
public class TitileBarLayout extends RelativeLayout implements OnClickListener
{

	/** 返回按钮 */
	public LinearLayout backButton;

	/** 类型按钮 */
	public ImageView typeButton;

	/** 筛选按钮 */
	public ImageView choiceButton;

	/** 点击接口 */
	private OnTitleBarClick onTitleBarClick;

	public TitileBarLayout(Context context, AttributeSet attrs, int defStyle)
	{
		super(context, attrs, defStyle);
		init(context);
	}

	public TitileBarLayout(Context context, AttributeSet attrs)
	{
		super(context, attrs);
		init(context);
	}

	public TitileBarLayout(Context context)
	{
		super(context);
		init(context);
	}

	/**
	 * 初始化
	 * 
	 * @param context
	 */
	private void init(Context context)
	{
		addView(View.inflate(context, R.layout.title_bar, null),
				new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
						LayoutParams.FILL_PARENT));

		backButton = (LinearLayout) findViewById(R.id.backButton);
		typeButton = (ImageView) findViewById(R.id.type_button);
		choiceButton = (ImageView) findViewById(R.id.choice_button);

		backButton.setOnClickListener(this);
		typeButton.setOnClickListener(this);
		choiceButton.setOnClickListener(this);

		isInEditMode();
	}

	@Override
	public void onClick(View v)
	{
		if (onTitleBarClick != null)
		{
			onTitleBarClick.onClick(v);
		}
	}

	public void setOnTitleClick(OnTitleBarClick onTitleBarClick)
	{
		this.onTitleBarClick = onTitleBarClick;
	}

	/**
	 * @author lung 下午3:05:32 2013
	 */
	public interface OnTitleBarClick
	{
		public void onClick(View view);
	}
	
	/**
	 * 设置类型按钮的背景
	 */
	public void setTypeBg(){
		
	}

}
